<template>
  <div class="CouponListItem">
    <div class="CouponListItemContent">
      <div class="CouponValue">
        <span class="CouponAmountLower" v-show="showFixedCoupon">¥</span>
        <span class="CouponAmount" v-show="showFixedCoupon">7</span>
        <span class="CouponAmount" v-show="showPercentageCoupon">{{ coupon.percentage }}</span>
        <span class="CouponPercentageLower" v-show="showPercentageCoupon">折</span>
      </div>
      <div class="CouponContent">
        <div class="CouponName">{{ coupon.name }}</div>
        <div class="CouponEndTime">
          有效期至 2020.09.30 23:32
        </div>
      </div>
    </div>
    <!-- <div class="CouponDescription van-hairline&#45;&#45;top">
       <span>详细信息</span>

     </div>-->
  </div>
</template>

<script>
import WhiteSpace from "@/components/WhiteSpace"
import { Col, Row } from "vant"
import { marketing } from "@mall/api-services"

const { CouponType } = marketing

export default {
  name: "CouponListItem",
  components: {
    WhiteSpace,
    [Row.name]: Row,
    [Col.name]: Col,
  },
  props: {
    coupon: marketing.TakeCoupon,
  },
  created() {
    const { coupon } = this
    console.log(coupon)
  },
  computed: {
    showFixedCoupon() {
      const { coupon } = this
      return coupon.type === CouponType.Fixed
    },
    showPercentageCoupon() {
      const { coupon } = this
      return coupon.type === CouponType.Percentage
    },
  },
}
</script>

<style lang="scss" scoped>
@import "../../styles/variables";

.CouponListItem {
  background: #fff;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 8px;

  .CouponListItemContent {
    display: flex;
    height: 56px;
    align-items: center;

    .CouponValue {
      color: $red;
      min-width: 100px;
      display: inline-flex;
      align-items: baseline;
      justify-content: center;

      .CouponAmountLower {
        font-size: 22px;

        &:first-child {
          margin-right: 6px;
        }
      }

      .CouponAmount {
        font-size: 34px;
      }

      .CouponPercentageLower {
        font-size: 18px;

        &:last-child {
          margin-left: 6px;
        }
      }
    }

    .CouponContent {
      .CouponName {
        font-size: 16px;
        font-weight: 500;
      }

      .CouponEndTime {
        font-size: 12px;
        color: $gray-6;
      }
    }
  }

  .CouponDescription {
    padding-top: 8px;

  }
}
</style>
